package com.yt.system.service.impl;

import com.yt.system.dao.RoleMapper;
import com.yt.system.domain.Role;
import com.yt.system.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public int updateRolePemission(Integer roid, String menu, String permission) {
        int i = roleMapper.updateRolePemission(roid, menu, permission);
        return i;
    }

    @Override
    public Role selectByPrimaryKey(Integer roid) {
        Role role = roleMapper.selectByPrimaryKey(roid);
        return role;
    }

    @Override
    public List<Role> selectAllRole() {
        List<Role> roles = roleMapper.selectAllRole();
        return roles;
    }

    @Override
    public int updateRole(Integer roid, String rolename, String content, Date updatetime) {
        System.out.println(roid+" "+rolename+" "+content);
        int i = roleMapper.updateRole(roid, rolename, content, updatetime);
        return i;
    }

    @Override
    public int deleteByPrimaryKey(Integer roid) {
        int i = roleMapper.deleteByPrimaryKey(roid);
        return i;
    }

    @Override
    public List<Role> selectLikeNameOrContent(String str) {
        str = '%'+str+'%';
        List<Role> roles = roleMapper.selectLikeNameOrContent(str);
        return roles;
    }

    @Override
    public int insertSelective(Role record) {
        int i = roleMapper.insertSelective(record);
        return i;
    }


}
